package com.example.demo.controller;

import com.example.demo.common.Result;
import com.example.demo.service.UserService;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("/api/user")
public class UserController {

    private final UserService userService;

    public UserController(UserService userService) {
        this.userService = userService;
    }

    @PutMapping("/password")
    public Result<Boolean> updatePassword(@RequestParam Long id, @RequestParam String newPassword) {
        boolean success = userService.updatePassword(id, newPassword);
        if (success) {
            return Result.success(true);
        }
        return Result.error("更新密码失败");
    }

    @DeleteMapping("/{id}")
    public Result<Boolean> deleteUser(@PathVariable Long id) {
        boolean success = userService.deleteUser(id);
        if (success) {
            return Result.success(true);
        }
        return Result.error("删除用户失败");
    }
} 